package com.gkd.controller.admin;


import com.gkd.pojo.dto.FavoriteDTO;
import com.gkd.pojo.dto.FavoritePageQueryDTO;
import com.gkd.result.PageResult;
import com.gkd.result.Result;
import com.gkd.service.FavoriteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 收藏相关接口
 */
@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/admin/favorite")
public class FavoriteController {

    @Autowired
    private FavoriteService favoriteService;


    /**
     * 分页查询
     * @param favoritePageQueryDTO
     * @return
     */
    @GetMapping
    public Result<PageResult> page(FavoritePageQueryDTO favoritePageQueryDTO){
        log.info("收藏分页查询:{}",favoritePageQueryDTO);
        PageResult pageResult=favoriteService.pageQuery(favoritePageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 取消收藏
     */
    @DeleteMapping
    public Result delete(@RequestBody List<Integer> favoriteIds){
        log.info("取消收藏:{}",favoriteIds);
        favoriteService.removeByIds(favoriteIds);
        return Result.success();
    }
    

}
